

package com.maoshi.shop.distribution.api.controller;

import com.maoshi.shop.common.config.Constant;
import com.maoshi.shop.distribution.comment.dto.DistributionRecruitSetDto;
import com.maoshi.shop.distribution.comment.model.DistributionRecruitSet;
import com.maoshi.shop.distribution.comment.service.DistributionRecruitSetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import ma.glasnost.orika.MapperFacade;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * 分销推广接口
 */
@RestController
@RequestMapping("/p/distribution/recruit")
@Api(tags = "分销推广接口")
@AllArgsConstructor
public class DistributionRecruitSetController {

    private final DistributionRecruitSetService distributionRecruitSetService;

    private final MapperFacade mapperFacade;


    @GetMapping("/info")
    @ApiOperation(value = "获取店铺推广数据" ,notes = "根据店铺id获取")
    public ResponseEntity<DistributionRecruitSetDto> info(){
        DistributionRecruitSet distributionRecruitSet = distributionRecruitSetService.getByShopId();
        if (Objects.equals(0,distributionRecruitSet.getState())) {
            distributionRecruitSet.setContent("");
        }
        return ResponseEntity.ok(mapperFacade.map(distributionRecruitSet, DistributionRecruitSetDto.class));
    }

}
